import java.util.Arrays;

public class Solution167 {
    public int[] twoSum(int[] numbers, int target) {
        int j=0;
        for (int i=numbers.length-1;i>j;i--){
            while (i>j && numbers[i]+numbers[j]<target){
                j++;
            }
            if (i!=j && numbers[i]+numbers[j]==target){
                return new int[]{j+1,i+1};
            }
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution167().twoSum(new int[]{2, 7, 11, 15}, 9)));
    }
}
